package com.yumingjaing.thread;

/**
 * @description: 测试线程的阻塞状态
 * @author: John
 * @version: TestBlockState.java, v1.0 2024年12月15日 06:23
 */
public class TestBlockState {
    public static void main(String[] args) throws InterruptedException {
        t1();
    }

    /**
     * 测试当主线程获取锁后，t1线程的状态：BLOCKED
     * @throws InterruptedException
     */
    private static void t1() throws InterruptedException {
        Thread t1 = new Thread(() -> {
            synchronized (TestBlockState.class){

            }
        });

        synchronized (TestBlockState.class){
            t1.start();
            Thread.sleep(500);
            System.out.println(t1.getState());
        }
    }
}